﻿/*
 * Creato da SharpDevelop.
 * Utente: Ciccio
 * Data: 25/12/2008
 * Ora: 12.39
 * 
 */

using System;
using System.Data;
using System.Xml;
using System.IO;

	/// <summary>
	/// Description of HandlerGMenu.
	/// </summary>
	public class HandlerGMenu : System.Web.UI.Page
	{

		void Page_Load(object o, EventArgs e ) {
			object mioValore =  Request.Form["multixml"];
			if(mioValore !=null) {
				AvviaElaborazione(mioValore);
			} else 
				Response.Write("NO XML");
		}
		
		
		void AvviaElaborazione (object xml) {
			DataSet ds = new DataSet();
			try {
				System.Xml.XmlReader xrd = System.Xml.XmlReader.Create(new System.IO.StringReader(xml.ToString()));
				ds.ReadXml(xrd);
				
				if(ds.Tables.Count==0) {
					Response.Write("NESSUN DATO");return;
				}
				if(!ds.Tables.Contains("item")) {
					Response.Write("NESSUN DATO(tabella)");return;
				}
				if(ds.Tables[0].Rows.Count==0) {
					Response.Write("NESSUN DATO(righe)");return;
				}
				ds.Tables["item"].Columns.Add(new DataColumn("query") );				
				Response.Write("Elaborazione per gruppo:\"" + gruppo +"\"<br/>");
				DataTable dt = ds.Tables["item"];
				Response.Write("TABELLA: " + dt.TableName + "<br/>");
				Response.Write("<table border=\"1\"><tr>");
				foreach(DataColumn dc in dt.Columns) 
					Response.Write("<td>"+dc.ColumnName + "</td>" );
				Response.Write("</tr>");
				foreach(DataRow dr in dt.Rows) {
					Response.Write("<tr>");
					foreach(DataColumn dc in dt.Columns) 
						Response.Write("<td>"+dr[dc.ColumnName] + "</td>" );
					Response.Write("</tr>");
				}
				Response.Write("</table><br/>Righe:" + dt.Rows.Count + "<hr/>");
			} catch (Exception ex) {
				Response.Write("ex: " + ex.ToString());
				
			}
		}		
	
		
	}
